/**
 * Created by ritamashin on 2017/11/11.
 */

import React, {Component} from 'react'
import {View, Text, StyleSheet, TouchableOpacity, Image} from 'react-native'
import {SCREEN_WIDTH, COLOR} from '../../../config'
import {CachedImage} from 'react-native-img-cache'

export default class HomepageGiftItem extends Component{

    static defaultProps = {
        giftItem : '',
        onPressItemAction : ''
    };

    render(){
        let {giftItem,onPressItemAction} = this.props;
        if (giftItem === undefined){
            return <View/>
        }
        if (onPressItemAction === undefined){
            onPressItemAction =  this._nonePressAction;
        }


        return (
            <TouchableOpacity activeOpacity={0.5}
                              onPress={() => onPressItemAction(giftItem)}
                              style={styles.itemWrapper}>
                <View>
                    <CachedImage source={{uri : giftItem['cover_image_url']}||
                    require('../../../../resource/Theme/ThemeDefaultBackground.png')}
                           style={styles.itemCover}/>
                    <Text style={styles.itemTitle}>{giftItem['title']}</Text>
                    <Text style={styles.itemIntroduce}>{giftItem['introduction']}</Text>
                    <View style={styles.separatorStyle}/>
                    <View>
                        <Image/>
                    </View>
                </View>
            </TouchableOpacity>
        )
    }

    _nonePressAction = (giftItem)=>{

    }

}

const styles = StyleSheet.create({
    itemWrapper : {
        backgroundColor : 'white',
        padding : 8
    },
    itemCover : {
        width : SCREEN_WIDTH - 16,
        height : (SCREEN_WIDTH - 16) * 9.0 / 16.0,
    },
    itemTitle : {
        color : COLOR.mainTextColor,
        fontSize : 18,
        fontWeight : 'bold',
        marginTop : 20,
    },
    itemIntroduce : {
        color: COLOR.subTextColor,
        fontSize: 14,
        marginTop: 20,
    },
    itemSeparatorLineStyle : {
        color : COLOR.separatorLineColor,
        height: 0.5,
        marginTop : 20,
    }



});

/**
 *
 "ad_monitors": [],
 "approved_at": 1509518579,
 "content_type": 1,
 "content_url": "http://www.liwushuo.com/posts/1049476/content",
 "cover_animated_webp_url": null,
 "cover_image_url": "http://img03.liwushuo.com/image/171101/6f2xavgzh.jpg-w720",
 "cover_webp_url": "http://img03.liwushuo.com/image/171101/6f2xavgzh.jpg?imageView2/2/w/720/q/85/format/webp",
 "created_at": 1509757200,
 "editor_id": 1296,
 "feature_list": [],
 "hidden_cover_image": false,
 "id": 1049476,
 "introduction": "它帮你说出你的故事，而你不用说话， 静静的站着就很美好",
 "labels": [],
 "liked": false,
 "likes_count": 9646,
 "limit_end_at": null,
 "media_type": 0,
 "published_at": 1509757200,
 "share_msg": "分享自 @礼物说",
 "short_title": "",
 "status": 0,
 "template": "",
 "title": "你的故事，让香水帮你说",
 "type": "post",
 "updated_at": 1509758059,
 "url": "http://www.liwushuo.com/posts/1049476"
 */
